﻿using System;

namespace Community.CsharpSqlite.Entity
{
    /*
** An instance of the following structure holds the context of a
** sum() or avg() aggregate computation.
*/
    //typedef struct SumCtx SumCtx;
    public class SumCtx
    {
        public Mem _M;
        public bool approx; /* True if non-integer value was input to the sum */
        public long cnt; /* Number of elements summed */
        public long iSum; /* Integer sum */
        public int overflow; /* True if integer overflow seen */
        public double rSum; /* Floating point sum */

        public Mem Context
        {
            get { return _M; }
            set
            {
                _M = value;
                if (_M == null || _M.z == null)
                    iSum = 0;
                else iSum = Convert.ToInt64(_M.z);
            }
        }
    };
}